Repository navigation
Name the enum member a parameter's default refers to - #151
Merged
Merged
Conversation
A command parameter whose default was an enum member with a non-zero value did not compile: the generator wrote the member's value as a bare integer, and C# converts only the literal 0 to an enum implicitly. The default now names the member, or casts when no member has that value. Fixes #75. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Mpdreamz
added a commit
to nullean/assembly-differ
that referenced
this pull request
Nov 14, 2026
assembly-differ now has a command per source: `release`, `files`, `nuget` and `github`. Each takes typed arguments and the shared options `-t`, `-f`, `-o` and `--fail-on`. `diff` and its provider specs still work unchanged, hidden from help. **Prompt summary:** The tool is being dusted off. Two strings split on `|`, with every flag shared by every source, are hard to read and hard to get right. argh can do better by making each source a proper subcommand. Existing callers must not break, so the current `diff` stays and is hidden. ## Why Every comparison was `diff "<provider>|<arg>|<arg>" "<provider>|<arg>"`. The help could not say which parts a provider takes, a typo surfaced as an exception, and a CI build had to repeat the package id and version it had just packed. `--help` listed one command whose usage was spread over a single parameter description. ## What #### A command per source `release <path>` compares a build with the release before it on nuget.org. Given a `.nupkg`, it reads the package id and version from it, so `assembly-differ release build/output/MyLib.1.3.0.nupkg` is the whole command. `files <old> <new>` takes a `.dll`, a directory or a `.nupkg` on each side. `nuget <id> <old> <new>` compares two published versions. `github` builds an older commit with the command you give. Each has its own `--help`, with examples. #### Packages as input A new provider reads a `.nupkg` and unpacks the assemblies of one target framework. `--framework` picks it. By default, `files` and `release` take the newest framework both sides ship, preferring .NET over .NET Standard over .NET Framework, and fail with a message when they share none. #### Shared options `-t`, `-f`, `-o` and `--fail-on` come from one `[AsParameters]` class, and argh validates `--format` and `--fail-on` against their allowed values. The default format of the commands is `markdown`; `diff` keeps `xml`. `--fail-on` stays a string until an argh release carries the enum default fix from [nullean/argh#151](nullean/argh#151). #### `diff` unchanged The comparison moved into `DiffRunner`, which `diff` and the commands share. `diff` is `[Hidden]`, still the default command, and every characterization snapshot is unchanged. The root help describes the tool and lists the new commands. #### Docs Both READMEs lead with the commands and keep a short section on provider specs. They also correct two claims: a provider spec without `diff` works, and Proc 0.13.0 marks `NoWrapInThread` obsolete; it does not add it. ## Verify ```bash mise run test # CommandsTests: help for every command, files on dlls, directories and generated .nupkgs, # release and nuget against nuget.org ./build.sh smokeaot # now also runs the nuget command with the native-AOT binary ``` **Out of scope:** `release` still fails when no earlier release exists. The next pull request resolves the baseline, including a first release. `action.yml` still calls `diff`; the action gets its own pull request. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
Mpdreamz
added a commit
to nullean/assembly-differ
that referenced
this pull request
Nov 14, 2026
`--fail-on` is now the `SuggestedVersionChange` enum. `--help` lists `none|patch|minor|major`, and argh rejects any other value. This needs Nullean.Argh 0.30.1. **Prompt summary:** argh 0.30.1 shipped the enum default fix from [nullean/argh#151](nullean/argh#151) so that assembly-differ's options could be typed. This takes it. ## Why An enum parameter whose default member was not `0` did not compile with argh before 0.30.1 ([nullean/argh#75](nullean/argh#75)). `SuggestedVersionChange.None` is `1`, so `--fail-on` was a string with `[AllowedValues]` and a hand-written `Enum.Parse`. ## What #### A typed option `ReportOptions.FailOn` is a `SuggestedVersionChange` that defaults to `None`. The commands pass it straight to the comparison. Argh matches values case-insensitively, as `Enum.Parse` did. #### `diff` unchanged The hidden `diff` keeps its string `--prevent-change` and its error for an unknown value, because its output is part of the contract. The characterization snapshots for it do not change. ## Verify ```bash mise run test assembly-differ files old.nupkg new.nupkg --fail-on major # exit 4 on a breaking change ``` Only the help snapshots change. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A command parameter that defaults to an enum member with a non-zero value now compiles. The generated code names the member,
global::App.OneBased.A, instead of writing its value as a bare integer.Prompt summary: assembly-differ wants a typed
--fail-on none|patch|minor|majoroption, and its enum's first member is not0. Today that only compiles as astringparsed by hand. This fixes the generator so the option can be the enum.Why
TryGetDefaultLiteralwrote an enum default as its underlying value,OneBased level = 1;. C# converts only the literal0to an enum implicitly, so any other value failed with CS0266 in the generated code (#75). Union case properties and options types already qualified their enum defaults; command parameters did not.What
Enum defaults name their member
A default whose value matches an enum member is written as that member, fully qualified. A value no member has, such as
(OneBased)7, is written as a cast. Nullable enums are handled the same way. Help already shows a qualified member by its CLI name, so[default: ...]is unchanged.A generator test that compiles the output
EnumDefaultTestsruns the generator and compiles what it produces, for a member default, a non-zero member, a nullable enum and a cast. All four fail onmainwith CS0266. The generator tests now referenceNullean.Argh.Core, because the generated code calls into it.Verify
🤖 Generated with Claude Code